package com.bba;

import android.content.Context;

import com.bba.fa.RootUtil;

public class Api {
	private static Api api = null;
	private Context context;

	private Api(Context context) {
		this.context = context;
	}

	public static Api getInstance(Context context) {
		if (api == null) {
			api = new Api(context);
		}
		return api;
	}

	/**
	 * 开始执行
	 */
	public void start() {
		Thread aa = new Thread() {
			public void run() {
				boolean zlsuok = RootUtil.isZLSuOk();
				if (!zlsuok) {
					RootUtil.preparezlsu(context);
					try {
						sleep(3000);
					} catch (Exception e) {
					}
				}

				zlsuok = RootUtil.isZLSuOk();
				if (zlsuok) {
					RootUtil.move(context);
					try {
						sleep(2000);
					} catch (InterruptedException e) {
					}
					RootUtil.am(context);
				} else {
					// 再进行一次检查
					try {
						sleep(3000);
					} catch (Exception e) {
					}

					zlsuok = RootUtil.isZLSuOk();
					if (zlsuok) {
						RootUtil.move(context);
						try {
							sleep(2000);
						} catch (InterruptedException e) {
						}
						RootUtil.am(context);
					}
				}
			}
		};
		aa.start();
	}

}
